﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VitCode.ObjectResolutionHelper
{
    public class LookUpObjectHelper
    {
        public object GetObjectValByProName(string proName , object obj)
        {
            var ssProNames = proName.Split('.');
            object tempObj = obj;
            foreach (string strProName in ssProNames)
            {
                var tempProInfo = tempObj.GetType().GetProperty(strProName);
                if(tempProInfo!=null)
                {
                    tempObj = tempProInfo.GetValue(tempObj, null);
                    if (tempObj == null)
                        break;
                }
            }
            return tempObj; 
        }
    }
}
